package com.huan.wc;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

//KEYINT map端的KEYOUT
//VALUEINT map端的VALUEOUT
public class MyReduce extends Reducer<Text, IntWritable,Text, IntWritable> {

    IntWritable v =   new IntWritable();
    @Override
    protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {

        int sum = 0;

        //TODO 累加求和
        for (IntWritable value : values) {
            //TODO 获取value
            int i = value.get();
            sum += i;
        }

        v.set( sum );
        context.write( key,v );

    }
}
